var beiMiCommon = require("BeiMiCommon");
cc.Class({
    extends: beiMiCommon,
    properties: {
        // atlas: {
        //     default: null,
        //     type: cc.SpriteAtlas
        // },
        roomId:{
            default:null ,
            type : cc.Label
        },
        roomNum:{
            default:null ,
            type : cc.Label
        },
        roomType:{
            default:null ,
            type : cc.Label
        },
        player:{
            default:null ,
            type : cc.Label
        },
        status:{
            default:null ,
            type : cc.Node
        },
        typeImg:{
            default:null ,
            type : cc.Node
        },
        backItem:{
            default:null ,
            type : cc.Node
        },
        readySp:{
            default: null,
            type: cc.SpriteFrame,
        },
        nowSp:{
            default: null,
            type: cc.SpriteFrame,
        },
        shuangSp:{
            default: null,
            type: cc.SpriteFrame,
        },
        maSp:{
            default: null,
            type: cc.SpriteFrame,
        },
        showid:{
            default:null ,
            type : cc.Label
        },
    },

    // use this for initialization
    onLoad: function () {
        this.showid.active = false;
    },
    init:function(obj){
        //console.log(obj)
        // roomArr = [
        //   {id: 205678, type: 1, name: "4人场 火拼双扣", total: 16, current: 7, player: "乘风破浪/勇哥/旭刚阳刚/sanm", status: 1}
        // ]

        this.roomId.string = "房间号 "+obj.showid;
        this.showid.string = obj.showid;//传值用
        //this.roomType.string = "["+obj.name+"]";
        this.roomNum.string = "局数 "+(obj.current || 1)+"/"+(obj.numofgames || 5);
        //this.player.string = obj.player.slice(0,10)+"...";
        this.player.string = "...";
        //游戏中
        if(obj.curpalyers!=4){
            this.status.getComponent(cc.Sprite).spriteFrame = this.readySp;
        }
        //等待中
        else{
            this.status.getComponent(cc.Sprite).spriteFrame = this.nowSp;
        }
        if(obj.matchtype && obj.matchtype=="shuangkou"){
            this.typeImg.getComponent(cc.Sprite).spriteFrame = this.shuangSp;
            this.roomType.string = "4人场 火拼双扣";
        }
        else if(obj.numofgames==5 || obj.numofgames==10 || obj.numofgames==15){
            this.typeImg.getComponent(cc.Sprite).spriteFrame = this.shuangSp;
            this.roomType.string = "4人场 火拼双扣";
        }
        else{
            this.typeImg.getComponent(cc.Sprite).spriteFrame = this.maSp;
            this.roomType.string = "4人场 开化麻将";
        }
    }
});
